package com.apimarket.util.kong;

import com.apimarket.entity.kong.Route;
import com.apimarket.entity.kong.Service;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;

//这个抽象类主要约定了，kong对外提供的对service操作的restful api
public abstract class KongService extends KongBase {
    protected static final String addPath = "/services";

    public static final String listPath = "/services";

    protected static final String deletePath = "/services";

    protected static final String updatePath = "/services";

    public KongService() {
    }

    public KongService(String baseUrl) {
        super(baseUrl);
    }

    public abstract Service addService(String url, String name) throws IOException, URISyntaxException;

    /**
     * 为保证Kong的pg数据库与业务自身的MySQL数据库一致性
     * id需由自己指定而非由Kong自主创建
     *
     * @see com.apimarket.service.ApiService
     */
    public abstract Service addService(String url, String name, String id) throws IOException, URISyntaxException;

    public abstract Service getService(String nameOrId) throws IOException, URISyntaxException;

    public abstract List<Service> listServices() throws IOException, URISyntaxException;

    public abstract void deleteService(String nameOrId) throws IOException, URISyntaxException;

    public abstract Service updateService(Service service) throws IOException, URISyntaxException;

    public abstract Service updateServiceById(String id,String url) throws IOException, URISyntaxException;

    public abstract List<Route> listRoutesByServiceId(String id) throws IOException, URISyntaxException;
}
